<?php
/*
 * @Author: your name
 * @Date: 2020-06-05 17:32:41
 * @LastEditTime: 2020-10-13 17:21:48
 * @LastEditors: Please set LastEditors
 * @Description: 部门管理
 * @FilePath: /special/application/adminapiv3/controller/asset_manage/MinistryController.php
 */

namespace app\adminapiv3\controller\asset_manage\ministry;

use app\adminapiv3\controller\BaseController;
use app\adminapiv3\service\asset_manage\ministry\MinistryService;
use think\Request;

class MinistryController extends BaseController
{

    /**
     * @name 列表
     * @author wx
     * @date 2019/10/25 11:06
     */
    public function list()
    {
        $server = new MinistryService();
        $list = $server->list();

        return $this->jsonOutPut($list);
    }

    /**
     * @name 添加
     * @author wx
     * @date 2019/10/25 11:06
     */
    public function add(Request $request)
    {
        $params = $request->only([
            'name','pid'
        ],'post');
        $this->validate($params,'Ministry.add');

        $server = new MinistryService();
        $returnData = $server->add($params['name'], $params['pid']);

        return $this->jsonOutPut($returnData);
    }

    /**
     * @name修改
     * @author wx
     * @date 2019/10/25 13:29
     */
    public function modify(Request $request)
    {
        //接收参数
        $params = $request->only([
            'name','id'
        ],'post');
        $this->validate($params,'Ministry.modify');

        $server = new MinistryService();
        $server->modify($params['id'], $params['name']);

        return $this->jsonOutPut();
    }

    /**
     * @name 删除
     * @author wx
     * @date time
     */
    public function del(Request $request)
    {

        //接收参数
        $params = $request->only([
            'id'
        ],'post');
        $this->validate($params,'Ministry.del');

        $server = new MinistryService();
        $server->del($params['id']);

        return $this->jsonOutPut();
    }

}